#include<iostream>
using namespace std;
typedef long long LL;
const int N = 5e5 + 10;
int arr[N];
LL tree[N];
int n, m;

int lowbit(int x)
{
	return x & -x;
}

void add(int x, int c)
{
	for (int i = x; i <= n; i += lowbit(i)) {
		tree[i] += c;
	}
}

LL sum(int x)
{
	LL res = 0;
	for (int i = x; i; i -= lowbit(i)) {
		res += tree[i];
	}
	return res;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	LL res = 0;
	for (int i = 1; i <= n; i++) {
		int y = arr[i];
		res += sum(n) - sum(y);
		add(y, 1);
	}
	cout << res << endl;
	return 0;
}